<template>
  <view class="">
    <mosowe-tree-list
      v-model="data"
      :treeData="treeList"
      text="name"
      nodeKey="permission"
      defaultShowChildren
      accordion
      multiple
    >
      <template #default="{ node }">
        <view class="test">{{ node.name }}</view>
      </template>
    </mosowe-tree-list>
  </view>
</template>

<script setup>
import { ref, watch } from "vue";
import { onShow } from "@dcloudio/uni-app";
const data = ref([]);
watch(
  () => data.value,
  () => {
    console.log(data.value);
  }
);
const treeList = [
  {
    _id: "64589cd409e29891989bc315",
    comment: "系统管理-目录",
    create_date: 0,
    enable: true,
    icon: "uni-icons-list",
    menu_id: "system",
    name: "系统管理",
    parent_id: "",
    permission: "system",
    sort: 99,
    type: 0,
    url: "",
    childrens: [
      {
        _id: "64589cd409e29891989bc316",
        comment: "用户管理",
        create_date: 0,
        enable: true,
        icon: "uni-icons-person-filled",
        menu_id: "system-user",
        name: "用户管理",
        parent_id: "system",
        permission: "system-user",
        sort: 99,
        type: 1,
        url: "/pages/system/users/users",
        childrens: [
          {
            _id: "64589cd409e29891989bc317",
            comment: "用户管理-查看",
            create_date: 0,
            enable: true,
            icon: "",
            menu_id: "system-user-see",
            name: "查看",
            parent_id: "system-user",
            permission: "system-user-see",
            sort: 99,
            type: 2,
            url: "",
            childrens: [],
            text: "查看",
            value: "system-user-see",
          },
          {
            _id: "64589cd409e29891989bc318",
            comment: "用户管理-新增",
            create_date: 0,
            enable: true,
            icon: "",
            menu_id: "system-user-add",
            name: "新增",
            parent_id: "system-user",
            permission: "system-user-add",
            sort: 99,
            type: 2,
            url: "",
            childrens: [],
            text: "新增",
            value: "system-user-add",
          },
          {
            _id: "64589cd409e29891989bc319",
            comment: "用户管理-编辑",
            create_date: 0,
            enable: true,
            icon: "",
            menu_id: "system-user-edit",
            name: "编辑",
            parent_id: "system-user",
            permission: "system-user-edit",
            sort: 99,
            type: 2,
            url: "",
            childrens: [],
            text: "编辑",
            value: "system-user-edit",
          },
          {
            _id: "64589cd409e29891989bc31a",
            comment: "用户管理-删除",
            create_date: 0,
            enable: true,
            icon: "",
            menu_id: "system-user-delete",
            name: "删除",
            parent_id: "system-user",
            permission: "system-user-delete",
            sort: 99,
            type: 2,
            url: "",
            childrens: [],
            text: "删除",
            value: "system-user-delete",
          },
          {
            _id: "64589cd409e29891989bc31b",
            comment: "用户管理-重置密码",
            create_date: 0,
            enable: true,
            icon: "",
            menu_id: "system-user-password",
            name: "重置密码",
            parent_id: "system-user",
            permission: "system-user-password",
            sort: 99,
            type: 2,
            url: "",
            childrens: [],
            text: "重置密码",
            value: "system-user-password",
          },
          {
            _id: "64589cd409e29891989bc31c",
            comment: "用户管理-用户状态设置，启用禁用",
            create_date: 0,
            enable: true,
            icon: "",
            menu_id: "system-user-status",
            name: "用户状态设置",
            parent_id: "system-user",
            permission: "system-user-status",
            sort: 99,
            type: 2,
            url: "",
            childrens: [],
            text: "用户状态设置",
            value: "system-user-status",
          },
        ],
        text: "用户管理",
        value: "/pages/system/users/users",
      },
      {
        _id: "64589cd409e29891989bc31d",
        comment: "菜单管理",
        create_date: 0,
        enable: true,
        icon: "uni-icons-list",
        menu_id: "system-menu",
        name: "菜单管理",
        parent_id: "system",
        permission: "system-menu",
        sort: 99,
        type: 1,
        url: "/pages/system/menus/menus",
        childrens: [
          {
            _id: "64589cd409e29891989bc31e",
            comment: "菜单管理-查看",
            create_date: 0,
            enable: true,
            icon: "",
            menu_id: "system-menu-see",
            name: "查看",
            parent_id: "system-menu",
            permission: "system-menu-see",
            sort: 99,
            type: 2,
            url: "",
            childrens: [],
            text: "查看",
            value: "system-menu-see",
          },
          {
            _id: "64589cd409e29891989bc31f",
            comment: "菜单管理-新增",
            create_date: 0,
            enable: true,
            icon: "",
            menu_id: "system-menu-add",
            name: "新增",
            parent_id: "system-menu",
            permission: "system-menu-add",
            sort: 99,
            type: 2,
            url: "",
            childrens: [],
            text: "新增",
            value: "system-menu-add",
          },
          {
            _id: "64589cd409e29891989bc320",
            comment: "菜单管理-编辑",
            create_date: 0,
            enable: true,
            icon: "",
            menu_id: "system-menu-edit",
            name: "编辑",
            parent_id: "system-menu",
            permission: "system-menu-edit",
            sort: 99,
            type: 2,
            url: "",
            childrens: [],
            text: "编辑",
            value: "system-menu-edit",
          },
          {
            _id: "64589cd409e29891989bc321",
            comment: "菜单管理-删除",
            create_date: 0,
            enable: true,
            icon: "",
            menu_id: "system-menu-delete",
            name: "删除",
            parent_id: "system-menu",
            permission: "system-menu-delete",
            sort: 99,
            type: 2,
            url: "",
            childrens: [],
            text: "删除",
            value: "system-menu-delete",
          },
        ],
        text: "菜单管理",
        value: "/pages/system/menus/menus",
      },
      {
        _id: "64589cd409e29891989bc322",
        comment: "角色管理",
        create_date: 0,
        enable: true,
        icon: "",
        menu_id: "system-roles",
        name: "角色管理",
        parent_id: "system",
        permission: "system-roles",
        sort: 99,
        type: 1,
        url: "/pages/system/roles/roles",
        childrens: [
          {
            _id: "64589cd409e29891989bc323",
            comment: "角色管理-查看",
            create_date: 0,
            enable: true,
            icon: "",
            menu_id: "system-roles-see",
            name: "查看",
            parent_id: "system-roles",
            permission: "system-roles-see",
            sort: 99,
            type: 2,
            url: "",
            childrens: [],
            text: "查看",
            value: "system-roles-see",
          },
          {
            _id: "64589cd409e29891989bc324",
            comment: "角色管理-新增",
            create_date: 0,
            enable: true,
            icon: "",
            menu_id: "system-roles-add",
            name: "新增",
            parent_id: "system-roles",
            permission: "system-roles-add",
            sort: 99,
            type: 2,
            url: "",
            childrens: [],
            text: "新增",
            value: "system-roles-add",
          },
          {
            _id: "64589cd409e29891989bc325",
            comment: "角色管理-编辑",
            create_date: 0,
            enable: true,
            icon: "",
            menu_id: "system-roles-edit",
            name: "编辑",
            parent_id: "system-roles",
            permission: "system-roles-edit",
            sort: 99,
            type: 2,
            url: "",
            childrens: [],
            text: "编辑",
            value: "system-roles-edit",
          },
          {
            _id: "64589cd409e29891989bc326",
            comment: "角色管理-删除",
            create_date: 0,
            enable: true,
            icon: "",
            menu_id: "system-roles-delete",
            name: "删除",
            parent_id: "system-roles",
            permission: "system-roles-delete",
            sort: 99,
            type: 2,
            url: "",
            childrens: [],
            text: "删除",
            value: "system-roles-delete",
          },
        ],
        text: "角色管理",
        value: "/pages/system/roles/roles",
      },
    ],
    text: "系统管理",
    value: "system",
  },
];
</script>